/*
 * Prostokat.cpp
 *
 * Version: $Id: Prostokat.cpp 61 2011-11-15 06:22:08Z s8376@pjwstk.edu.pl $
 */
#include <iostream>
#include <string.h>
#include "Punkt.h"
#include "Prostokat.h"

using namespace std;

Prostokat::Prostokat(char* name, Punkt p1, Punkt p2) :
    m_name(strdup(name)), m_p1(p1), m_p2(p2)
{
    cout << "Tworze obiekt klasy Prostokat" << endl;
}
Prostokat::Prostokat(const Prostokat& ob) :
    m_name(strdup(ob.m_name)), m_p1(ob.m_p1), m_p2(ob.m_p2)
{
    cout << "Kopiuje obiekt klasy Prostokat" << endl;
}
Prostokat::~Prostokat()
{
    cout << "Niszcze obiekt klasy Prostokat" << endl;
    delete[] m_name;
    m_name = 0;
}
void Prostokat::area()
{
    int width, height;

    width = m_p2.getX() - m_p1.getX();
    height = m_p2.getY() - m_p1.getY();

    cout << "Pole prostokata " << m_name << ": " << (width * height) << endl;
}
void Prostokat::show()
{
    cout << "Prostokąt: " << m_name << endl;

    m_p1.show();
    m_p2.show();
}
